package controller.transform;

import javax.vecmath.Vector3d;

import component.Ball;
import component.Tube;
import component.group.ComponentGroup;

public abstract class AlignToPlane extends AlignMode {

	private Ball pivot = null;
	
	public AlignToPlane(Gui gui, Scene scene, Ball pivot) {
		super(gui, scene, pivot);
		this.pivot = pivot;
		setDefaultText();
	}

	@Override
	protected void tubeClicked(Tube tube) {
		ComponentGroup group = this.makeSelection(tube);
		if (group == null) return;
		
		Vector3d tubeVector = tube.getOrientation().getVector();
		Vector3d alignTo = getAlignToVector(tubeVector);
		alignGroup(group, this.getClosestRotation(tubeVector, alignTo), pivot.getPos());
	}
	

	
	protected abstract Vector3d getAlignToVector(Vector3d tubeVector);
	
}
